Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fill_buf by not calling poll_fill_buf twice #4084

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

Darksonn
Copy link
Contributor

@Darksonn Darksonn commented Aug 31, 2021

There are some IO resources which hit the panic when calling poll_fill_buf twice, e.g. a BufReader<File> will do this when you are at EOF.

A safe alternative is to check for empty slices and handle those in a special way, but I prefer this as it is a more robust solution.

Fixes: #4085

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-io Module: tokio/io labels Aug 31, 2021
@UebelAndre
Copy link

Should some kind of regression test be added here?

@Darksonn
Copy link
Contributor Author

I don't think it's particularly necessary here, but I can add one.

Darksonn added a commit that referenced this pull request Aug 31, 2021
use tokio_test::assert_ok;

#[tokio::test]
async fn fill_buf_file() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take it or leave it: maybe worth a comment summarizing the bug this is a regression test for (and a link to the original issue?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really feel like waiting for CI over again, since I am making a release immediately after merging this.

@Darksonn Darksonn merged commit 1409041 into tokio-rs:master Aug 31, 2021
@Darksonn Darksonn deleted the fill_buf_polonius branch August 31, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-io Module: tokio/io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in AsyncBufReadExt::fill_buf
4 participants